const express = require("express");
const bodyParser = require("body-parser");
const passport = require("passport");
const cors = require("cors");
const app = express();

// 跨域
app.use(cors());

// 用户,详情
const users = require("./routes/users");
const details = require("./routes/details");

// 使用bodyParser中间件
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

app.get("/", (req, res) => {
  res.send({ msg: "mysql" });
});

// passport 初始化
app.use(passport.initialize());

require('./config/passprot')(passport);


// 使用routes
app.use("/users", users);
app.use("/details", details);

const port = process.env.PORT || 5210;
process.env['DEBUG'] = 'express:*';

app.listen(port, () => {
  console.log(`服务器启动成功，端口号${port}`);
});